import {
	createRouter,
	createWebHashHistory
} from "vue-router"

// 1. 导入路由组件.
import home from '@/views/home/index.vue' //@表示是src目录
import todo from "@/views/todo/index.vue"
// 2. 定义一些路由
// 每个路由都需要映射到一个组件。
// 我们后面再讨论嵌套路由。
const routes = [{
		path: '/home',
		component: home
	},
	{
		path: '/',
		component: () => import('@/views/test/index.vue') //懒加载
	},
	{
		path: '/todo',
		component: todo
	},
	{
		path: '/learn',
		component: () => import('@/views/learn/index.vue') //懒加载
	},
	{
		path: '/goodsManage',
		component: () => import('@/views/goodsManage/index.vue')
	},
	{
		path: '/pm25',
		component: () => import('@/views/pm25/index.vue')
	},
	{
		path: '/telphone',
		component: () => import('@/views/telphone/index.vue')
	},

	{ //商品列表
		path: "/productList",
		name: "productList",
		component: () => import('@/views/product/productList.vue')
	},
	{ // 商品详情
		path: "/productDetail/:id",
		props: true, //props属性设置
		name: "productDetail",
		component: () => import('@/views/product/productDetail.vue')
	},


	{ // 不存在提示
		path: '/:pathMatch(.*)*',
		name: "notFound",
		component: () => import('@/views/NotFound.vue')
	},


]

// 3. 创建路由实例并传递 `routes` 配置
const router = createRouter({
	// 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
	history: createWebHashHistory(),
	routes, // `routes: routes` 的缩写
})

export default router